package com.heima.admin.controller.v1;

import com.heima.admin.service.AdChannelService;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

// 频道管理
@RestController
@RequestMapping("/api/v1/channel")
@MapperScan("com.heima.admin.mapper")
public class AdChannelController {

    @Autowired
    private AdChannelService adChannelService;

    /**
     * 删除频道
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id) {
        return adChannelService.deleteChannel(id);
    }

    /**
     * 频道名称模糊分页查询
     * @param channelDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult getChannelList(@RequestBody ChannelDto channelDto){
        return adChannelService.getChannelList(channelDto);
    }

    /**
     * 保存频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return adChannelService.saveChannel(wmChannel);
    }

    /**
     * 修改频道
     * @param wmChannel
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel) {
        return adChannelService.updateChannel(wmChannel);
    }

}
